from django.db import models


# Create your models here.

# 一张卡片携带的信息
class Card(models.Model):
    id = models.AutoField(primary_key=True)  # 卡片id，主键
    title = models.CharField(max_length=20)
    content = models.CharField(max_length=300)
    user = models.CharField(max_length=30)  # 所属用户，用户可以删除自己发布的灵感卡片
    likes = models.PositiveIntegerField(default=0)  # 点赞数
    comments = models.PositiveIntegerField(default=0)  # 评论数
    collections = models.PositiveIntegerField(default=0)  # 收藏数
    created_time = models.DateTimeField(auto_now_add=True)


# 收藏数据库
class Collection(models.Model):
    user = models.CharField(max_length=50)  # 用户
    card_id = models.PositiveIntegerField()  # 用户收藏的卡片id


# 评论数据库
class Comment(models.Model):
    card_id = models.PositiveIntegerField()  # 卡片id
    comment = models.CharField(max_length=200)  # 评论在该卡片id下内容
    user = models.CharField(max_length=30)  # 谁评论的
    created_time = models.DateTimeField(auto_now_add=True)  # 评论时间


# 点赞数据库
class Likes(models.Model):
    user = models.CharField(max_length=50)      # 用户
    card_id = models.PositiveIntegerField()     # 用户点赞的卡片id
    state = models.BooleanField(default=False)  # 当前id点赞的状态
